//
//  TanHunTopicCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/12/10.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "TanHunTopicCell.h"

@implementation TanHunTopicCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
}

- (void)fillWithModel:(CommunityThemeModel *)model {
    
    if (model.themeTitle.length >5) {
        self.mainTitleLab.textAlignment = NSTextAlignmentLeft;
    } else {
        self.mainTitleLab.textAlignment = NSTextAlignmentCenter;
    }
    self.mainTitleLab.text = [NSString stringWithFormat:@"%@",model.themeTitle];
    [self.bgImageView sd_setImageWithURL:[NSURL URLWithString:model.themeUrl] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    
    NSInteger index = model.index%4;
    switch (index) {
        case 0:{
            self.alphaView.backgroundColor = [UIColorHex(0x243A49) colorWithAlphaComponent:0.7];
        } break;
        case 1:{
            self.alphaView.backgroundColor = [UIColorHex(0x5A462C) colorWithAlphaComponent:0.7];

        } break;
        case 2:{
            self.alphaView.backgroundColor = [UIColorHex(0x6D3E3E) colorWithAlphaComponent:0.7];

        } break;
        case 3:{
            self.alphaView.backgroundColor = [UIColorHex(0x3D3B6C) colorWithAlphaComponent:0.7];

        } break;
        default:
            break;
    }
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self pp_clipCorners:UIRectCornerAllCorners radius:6];
    });
}

@end
